<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	
</body>
</html>
<script>
	//程序运行的三大结构
	//1.顺序结构
	//2.分支结构
	//3.循环结构

	//if语句
	//第一种情况
	var a = 20;
	if (a % 2 ==0){
		a += 10;
	}
	document.write(a);

	//第二种情况
	 a = 5;
	if (a % 2 ==0){
		a += 10;
	}else{
		a -= 10;
	}
	document.write(a);

	//第三种情况
	//级联式
	var score = 100;
	if( score ==100){
		alert("很优秀");
	}else if (score >=90 && score < 100){
		alert("优秀");
	}
	document.write(score);

	//还可以这样写
	a = 5;
	if (a % 2 == 0) alert("偶数");
		else alert("奇数");


		//三元运算符
		// ? :
		var genderOfCQY = "男";
		var str1 = genderOfCQY =="男" ? "胖胖嫁给他":"庞攀不嫁给他";
		document.write(str1);
		/*等价于
		var str;
		if (genderOfCQY == "男"){
	         str = "胖胖嫁给他"
		} */


        //交换两个变量的值
		var a = 5;
		var b = 20;
		var temp = a;
		    a = b;
		    b = temp;
		    document.write("a = " + a + ", b = " + b + "<br>");

		    //.....
		    a = a + b;
		    b = a - b;
		    a = a - b;
		    document.write("a = " + a + ", b = " + b + "<br>");
            //........
            b = a + b - (a = b);
            document.write("a = " + a + ", b = " + b + "<br>");



	






</script>